function varargout = Config(varargin)
% CONFIG MATLAB code for Config.fig
%      CONFIG, by itself, creates a new CONFIG or raises the existing
%      singleton*.
%
%      H = CONFIG returns the handle to a new CONFIG or the handle to
%      the existing singleton*.
%
%      CONFIG('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CONFIG.M with the given input arguments.
%
%      CONFIG('Property','Value',...) creates a new CONFIG or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Config_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Config_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Config

% Last Modified by GUIDE v2.5 06-Nov-2012 20:15:30

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Config_OpeningFcn, ...
                   'gui_OutputFcn',  @Config_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
end

% --- Executes just before Config is made visible.
function Config_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Config (see VARARGIN)

% Choose default command line output for Config
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Config wait for user response (see UIRESUME)
% uiwait(handles.Config);
end

% --- Outputs from this function are returned to the command line.
function varargout = Config_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
end


% --- Executes on button press in btnCancel.
function btnCancel_Callback(hObject, eventdata, handles)
% hObject    handle to btnCancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    close(Config);
end


% --- Executes on button press in btnOK.
function btnOK_Callback(hObject, eventdata, handles)
% hObject    handle to btnOK (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    %get value from input. :))
    txtInput = get(handles.txtInput,'String');
    txtOutput = get(handles.txtOutput,'String');
    txtRules = get(handles.txtRules,'String');
    txtTrongtam = get(handles.txtTrongtam,'String');
    txtXichma = get(handles.txtXichma,'String');
    txtTheta = get(handles.txtTheta,'String');
    txtTrongso = get(handles.txtTrongso,'String');
    if(isempty(txtRules) || isempty(txtTrongtam) || isempty(txtXichma) || isempty(txtTheta) || isempty(txtTrongso))
         msgbox('Please fill all input','Error');   
    elseif(isempty(str2num(txtRules)) || ...
        isempty(str2num(txtTrongtam)) || isempty(str2num(txtXichma)) || isempty(str2num(txtTheta)) || isempty(str2num(txtTrongso)))
        msgbox('Input is invalid','Error');
    else
        %send data to RFNN
        %handles.config = [12 34];
        set(RFNN, 'UserData', [str2num(txtInput) str2num(txtOutput) str2num(txtRules) ...
            str2double(txtTrongtam) str2double(txtXichma) str2double(txtTheta) str2double(txtTrongso)]);
        close(Config);
    end
end



function txtInput_Callback(hObject, eventdata, handles)
% hObject    handle to txtInput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtInput as text
%        str2double(get(hObject,'String')) returns contents of txtInput as a double
end

% --- Executes during object creation, after setting all properties.
function txtInput_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtInput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtOutput_Callback(hObject, eventdata, handles)
% hObject    handle to txtOutput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtOutput as text
%        str2double(get(hObject,'String')) returns contents of txtOutput as a double
end

% --- Executes during object creation, after setting all properties.
function txtOutput_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtOutput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtRules_Callback(hObject, eventdata, handles)
% hObject    handle to txtRules (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtRules as text
%        str2double(get(hObject,'String')) returns contents of txtRules as a double
end

% --- Executes during object creation, after setting all properties.
function txtRules_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtRules (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtTrongtam_Callback(hObject, eventdata, handles)
% hObject    handle to txtTrongtam (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtTrongtam as text
%        str2double(get(hObject,'String')) returns contents of txtTrongtam as a double
end

% --- Executes during object creation, after setting all properties.
function txtTrongtam_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtTrongtam (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtXichma_Callback(hObject, eventdata, handles)
% hObject    handle to txtXichma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtXichma as text
%        str2double(get(hObject,'String')) returns contents of txtXichma as a double
end

% --- Executes during object creation, after setting all properties.
function txtXichma_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtXichma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtTheta_Callback(hObject, eventdata, handles)
% hObject    handle to txtTheta (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtTheta as text
%        str2double(get(hObject,'String')) returns contents of txtTheta as a double
end

% --- Executes during object creation, after setting all properties.
function txtTheta_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtTheta (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end


function txtTrongso_Callback(hObject, eventdata, handles)
% hObject    handle to txtTrongso (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtTrongso as text
%        str2double(get(hObject,'String')) returns contents of txtTrongso as a double
end

% --- Executes during object creation, after setting all properties.
function txtTrongso_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtTrongso (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
end
